using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Input;
using System.Windows;
using CoastToCoast.Game;
using CoastToCoast.Game.Units;
using CoastToCoast.Client;

namespace CoastToCoast.Client.Views {
    public static class ViewFactory {
        public static UnitView CreateUnitView(Unit unit, CellView cellView) {
            UnitView view = null;
            if (unit is Infantry) {
                view = new InfantryView();
            }
            else if (unit is Tank) {
                view = new TankView();
            }
            else if (unit is Fighter) {
                view = new FighterView();
            }
            else if (unit is Bomber) {
                view = new BomberView();
            }
            else if (unit is Battleship) {
                view = new BattleshipView();
            }
            else if (unit is Transport) {
                view = new TransportView();
            }
            else if (unit is Submarine) {
                view = new SubmarineView();
            }
            if (view == null) {
                throw new InvalidOperationException("Unknown game object for view: " + unit);
            }

            view.Unit = unit;
            view.CellView = cellView;

            return view;
        }

        public static TerrainView CreateTerrainView(Terrain terrain, CellView cellView) {
            TerrainView tview = null;
            if (terrain is LandTile) {
                tview = new LandTileView();
            }
            else if (terrain is SeaTile) {
                tview = new SeaTileView();
            }
            if (tview == null) {
                throw new InvalidOperationException("Unknown terrain object for view: " + terrain);
            }

            tview.CellView = cellView;
            tview.Terrain = terrain;

            return tview;
        }
    }
}
